extends Control

signal pressed

onready var label: Label = $Label
onready var progress: TextureProgress = $Progress
onready var tween: Tween = $Tween

var entered = false

func _input(event: InputEvent) -> void:
	if event is InputEventMouseButton and entered:
		if event.pressed == false:
			progress.fill_mode = TextureProgress.FILL_BILINEAR_LEFT_AND_RIGHT
			tween.interpolate_property(progress, "value",
				100, 0, 0.2,
				Tween.TRANS_CIRC, Tween.EASE_OUT)
			tween.start()
			emit_signal("pressed")
		else:
			progress.fill_mode = TextureProgress.FILL_BILINEAR_LEFT_AND_RIGHT
			tween.interpolate_property(progress, "value",
				0, 100, 0.2,
				Tween.TRANS_CIRC, Tween.EASE_OUT)
			tween.start()

func _on_mouse_entered() -> void:
	entered = true
	progress.fill_mode = TextureProgress.FILL_BILINEAR_TOP_AND_BOTTOM
	tween.interpolate_property(progress, "value",
		100, 0, 0.2,
		Tween.TRANS_CIRC, Tween.EASE_OUT)
	tween.start()


func _on_mouse_exited() -> void:
	entered = false
	progress.fill_mode = TextureProgress.FILL_BILINEAR_TOP_AND_BOTTOM
	tween.interpolate_property(progress, "value",
		0, 100, 0.2,
		Tween.TRANS_CIRC, Tween.EASE_OUT)
	tween.start()
